//
//  GCMSBPlanTableViewCell.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/11/21.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMSBPlanTableViewCell.h"

@implementation GCMSBPlanTableViewCell{
    
    UIView * _bgView;
    UIImageView *_rightImageV;
    UILabel *_titleLabel;
    UILabel *_detailLabel;
    UILabel *_JDRLabel;
    UILabel *_SLRLabel;
    UILabel *_ZTLabel;
    UILabel *_dataLabel;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    _bgView = [[UIImageView alloc]init];
    _bgView.frame =CGRectMake(10, 10,SCREEN_WIDTH - 20, 110 );
    _bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_bgView];
    
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.frame = CGRectMake(20,10,_bgView.bounds.size.width, 30);
    _titleLabel.textColor = [UIColor colorWithRed:0.58 green:0.65 blue:0.65 alpha:1.00];
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    [_bgView addSubview:_titleLabel];
    
    _detailLabel = [[UILabel alloc]init];
    _detailLabel.frame = CGRectMake(20 ,40 , _bgView.bounds.size.width - 40, 30);
    _detailLabel.textColor = [UIColor colorWithRed:0.58 green:0.65 blue:0.65 alpha:1.00];
    _detailLabel.textAlignment = NSTextAlignmentLeft;
    [_bgView addSubview:_detailLabel];
    
    _JDRLabel = [[UILabel alloc]init];
    _JDRLabel.frame = CGRectMake(20,70, _bgView.bounds.size.width - 40,30 );
    _JDRLabel.textAlignment = NSTextAlignmentLeft;
    _JDRLabel.font = [UIFont systemFontOfSize:17];
    _JDRLabel.textColor = [UIColor colorWithRed:0.58 green:0.65 blue:0.65 alpha:1.00];
    [_JDRLabel setNumberOfLines:0];
    _JDRLabel.lineBreakMode = NSLineBreakByWordWrapping;
    [_bgView addSubview:_JDRLabel];
    
    
}
-(void)setPlanModel:(GCMSBPlanModel *)planModel{
    
    _planModel = planModel;
    NSArray *a  = [_planModel.lastTime componentsSeparatedByString:@" "];
    _titleLabel.text = [NSString stringWithFormat:@"类       别:  %@",_planModel.type];
    _detailLabel.text = [NSString stringWithFormat:@"最后巡检时间:  %@",a[0]];
    _JDRLabel.text = [NSString stringWithFormat:@"下次巡检时间:  %@",_planModel.nextTime];
    
}

-(void)setOtherModel:(GCMOtherModel *)otherModel{
    _otherModel = otherModel;
    _titleLabel.text = [NSString stringWithFormat:@"设备号:  %@",_otherModel.idd];
    _detailLabel.text = [NSString stringWithFormat:@"设备名称:  %@",_otherModel.name];
    _JDRLabel.text = [NSString stringWithFormat:@"设备值:%@",_otherModel.value];
    
    CGSize size = CGSizeMake(_bgView.bounds.size.width - 40,CGFLOAT_MAX);
    UIFont* theFont = [UIFont systemFontOfSize:17];
    //计算文字所占区域
    CGSize labelSize = [_JDRLabel.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : theFont} context:nil].size;
    _JDRLabel.frame = CGRectMake(20,70, _bgView.bounds.size.width - 40,labelSize.height );
    _bgView.frame =CGRectMake(10, 10,SCREEN_WIDTH - 20, 110 + labelSize.height - 30 );
    
}
@end
